package com.ssm.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ssm.sfzy.entity.ConsultProblem;
import com.ssm.sfzy.entity.CourseProblem;
import com.ssm.sfzy.mapper.CourseProblemMapper;
import com.ssm.sfzy.service.CourseProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author jitwxs
 * @date 2024年04月01日 10:33
 */
@Service
public class CourseProblemServiceImpl implements CourseProblemService {
    @Autowired
    private CourseProblemMapper courseProblemMapper;
    @Override
    public void add(CourseProblem entity) {
        courseProblemMapper.insert(entity);
    }

    @Override
    public void edit(CourseProblem entity) {
        courseProblemMapper.update(entity);
    }

    @Override
    public void remove(Integer id) {
        courseProblemMapper.delete(id);
    }

    @Override
    public void removeBatch(Integer[] ids) {
        courseProblemMapper.deleteBatch(ids);
    }

    @Override
    public List<CourseProblem> find(CourseProblem entity) {
        return courseProblemMapper.select(entity);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, CourseProblem entity) {
        PageHelper.startPage(pageNum,pageSize);
        List<CourseProblem> list = courseProblemMapper.select(entity);
        PageInfo<CourseProblem> pageInfo = new PageInfo<>(list);
        Map<String,Object> map = new HashMap<>();
        map.put("list",pageInfo.getList());
        map.put("total",pageInfo.getTotal());
        return map;
    }

    @Override
    public CourseProblem findById(Integer id) {
        return courseProblemMapper.selectById(id);
    }

}
